package org.cyk.bilibili_json_read.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.cyk.bilibili_json_read.cmd.ReadJsonCmd;
import org.cyk.bilibili_json_read.model.JsonContentDTO;
import org.cyk.bilibili_json_read.service.IReadJsonService;
import org.springframework.stereotype.Service;

import java.time.Duration;
import java.time.temporal.ChronoUnit;

@Slf4j
@Service
public class ReadJsonService implements IReadJsonService {

    @Override
    public String readJson(JsonContentDTO jsonContent) {
        long start = System.nanoTime();
        String result = ReadJsonCmd.cmd(jsonContent.getJson());
        long end = System.nanoTime();
        Duration formattedDuration = Duration.of(end - start, ChronoUnit.NANOS);
        log.info("执行时间: " + formattedDuration.toMillis()+ "ms");
        return result;
    }

}
